package org.ala.tiktools.sharddb.mybatis.pager.with_order;

import org.ala.tiktools.sharddb.mybatis.interceptor.Shard;
import org.ala.tiktools.sharddb.mybatis.router.ShardInfo;

import java.util.Map;

/**
 * @author ala
 * @date 2025-03-10 14:01
 */
public class ShardCountDO {
    /**
     *  总数
     */
    protected int total;
    /**
     *  每个分库分表的数量
     */
    protected Map<ShardInfo, Integer> shards;


    public static ShardCountDO build(Map<ShardInfo, Integer> shards) {
        ShardCountDO d = new ShardCountDO();
        d.shards = shards;
        d.total = shards.values().stream().mapToInt(i -> i.intValue()).sum();
        return d;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public Map<ShardInfo, Integer> getShards() {
        return shards;
    }

    public void setShards(Map<ShardInfo, Integer> shards) {
        this.shards = shards;
    }
}
